package com.yannuo.util;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class LogginHandle implements InvocationHandler {
    //声明被代理的对象
   private final Object targer;

    public LogginHandle(Object targer) {
        this.targer = targer;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //前置增强
        System.out.println("日志开始执行："+method.getName());

        //原始方法
        Object result = method.invoke(targer, args);

        //后置增强
        System.out.println("日志执行完成："+method.getName());
        return result;
    }
}
